<include file="public@header"/>
</head>
<style>
    .form-search label {
        width: 300px;
    }
</style>
<body>

<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:url('file/index')}">档案管理</a></li>
        <li><a href="{:url('file/add')}">档案添加</a></li>
    </ul>
    <form class="well form-search" method="get" action="{:url('file/index')}">
        <label>
            档案号:
            <input type="text" name="file_num" class="form-control" value="{:input('request.file_num/s','')}"
                   placeholder="请输入档案号">
        </label>
        <label>
            墓位号:
            <input type="text" name="tomb_num" class="form-control" value="{:input('request.tomb_num/s','')}"
                   placeholder="请输入墓位号">
        </label>
        <label>
            购墓人:
            <input type="text" name="customer_name" class="form-control" value="{:input('request.customer_name/s','')}"
                   placeholder="请输入购墓人">
        </label>
        </br>
        购墓时间: <input type="text" class='js-date form-control' name="start_time"
                     value="{:input('request.start_time/s','')}" placeholder="请输入开始时间">
        ~
        <input type="text" class='js-date form-control' name="end_time" value="{:input('request.end_time/s','')}"
               placeholder="请输入结束时间">
        <input type="submit" class="btn btn-primary" value="搜索"/>
        <a class="btn btn-danger" href="{:url('file/index')}">清空</a>
    </form>
    <table class="table table-hover table-bordered table-list">
        <form class="well form-search js-ajax-form" id="form1" action="##">
            <thead>
            <tr>
                <th width="1%"><label><input type="checkbox" class="js-check-all" data-direction="x"
                                             data-checklist="js-check-x"></label></th>
                <th width="5%">序号</th>
                <th width="7%">墓位号
                    <button class="btn btn-primary btn-sm" type="submit" id="ajaxButton" name="btnname"
                            data-action="{:url('file/index')}">{:lang('SORT')}
                    </button>
                </th>
                <th width="7%">档案号
                    <button class="btn btn-primary btn-sm js-ajax-submit" type="submit" id="th2" >{:lang('SORT')}
                    </button>
                </th>
                <th width="6%">购墓人</th>
                <th width="10%">购墓时间
                    <button class="btn btn-primary btn-sm js-ajax-submit" type="submit" id="th3">{:lang('SORT')}
                    </button>
                </th>
                <th width="20%">所在区域</th>
                <th width="20%">具体位置</th>
                <th width="10%">{:lang('ACTIONS')}</th>
            </tr>
            </thead>
        </form>
        <tbody>
        <foreach name="results" item="vo">
            <tr>
                <td><input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]"
                           value="{$vo.id}"></td>
                <td>{$vo.id}</td>
                <td>{$vo.tomb_num}</td>
                <td>{$vo.file_num}</td>
                <td>{$vo.customer_name}</td>
                <td>{$vo.closing_time|date='Y-m-d'}</td>
                <td>{$vo.tomb_region}</td>
                <td>{$vo.tomb_address}</td>
                <td>
                    <a href="{:url('file/edit',array('id'=>$vo['id']))}">{:lang('EDIT')}</a> |
                    <a href="{:url('file/delete',array('id'=>$vo['id']))}" class="js-ajax-delete">{:lang('DELETE')}</a>
                </td>
            </tr>
        </foreach>
        </tbody>
    </table>
    <div class="pagination">{$page}</div>
    <script type="text/javascript" src="__STATIC__/js/admin.js?v={:time()}"></script>
    <script>

        (function() {
            var httpRequest;
            document.querySelector("#ajaxButton").addEventListener('click', makeRequest);

            function makeRequest() {
                httpRequest = new XMLHttpRequest();

                if (!httpRequest) {
                    alert('Giving up :( Cannot create an XMLHTTP instance');
                    return false;
                }
                httpRequest.onreadystatechange = alertContents;
                httpRequest.open('GET', 'index.html');
                httpRequest.send();
            }

            function alertContents() {
                if (httpRequest.readyState === XMLHttpRequest.DONE) {
                    if (httpRequest.status === 200) {
                        alert(httpRequest.responseText);
                    } else {
                        alert('There was a problem with the request.');
                    }
                }
            }
        })();

    </script>
</div>
</body>
</html>